Skip to content

fix(desktop): account deletion finishes its local cleanup, native avatar downloads stay within the app's policy, links through the opener plugin - #302

Merged
Aizen93 merged 6 commits into
developfrom
fix/desktop-shell-hygiene
Nov 19, 2026

Conversation

@Aizen93

@Aizen93 Aizen93 commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What was wrong

  • Account deletion left the vault key on the device. Self-service deletion dropped the local E2E vault, but the pickle key that opens it stayed in the OS credential store (desktop app) and in localStorage (browser build, or a desktop install whose keychain write had fallen back to it). There was no command to remove it.
  • The page could change before an account deletion's local cleanup ran. While the server deletes an account it sends force:logout to every socket of the account (the deleting client's included) before its transaction and again after the commit, and refuses the account's other requests. The force:logout handler and the lost-session path change the page to the login page with no link to the deletion in flight: a page change before the answer skipped the whole local cleanup (the vault, its key, the secure-channel pins, the trusted-device token), and one during the cleanup could cut the key removal short.
  • The native avatar download fetched from whatever http(s) host the webview named, and followed redirects. On Windows a notification's avatar is downloaded in native code, which the webview's content security policy does not bind; the command checked only the scheme of the base it was given.
  • notifications.ts imported Tauri modules statically. It was the only file under apps/desktop/src that did, so @tauri-apps/plugin-notification and @tauri-apps/api/core were part of what every browser session downloads at startup.
  • External links opened only through a click script the shell plugin injected. Links with target="_blank" reached the system browser because tauri-plugin-shell injects a click handler that nothing in the app's source showed. That plugin's open API is deprecated, and the plugin also carries process-execution commands the app never used.
  • Blocking commands ran on the window's thread. The keychain commands of the vault key and the avatar notification were synchronous commands, which Tauri runs on the main thread: a keychain call, or the avatar download (up to 10 s), held the thread that paints the window.

What the code does now

  • The vault key goes with the vault (Account deletion leaves the E2E vault's pickle key in the OS keychain (and localStorage) #121). The shell has e2e_pickle_key_delete(user_id) beside the get and set commands: the same user-id check, the service from keychain_services, and a missing entry counts as deleted. PickleKeyProvider has remove(userId): the keychain backend removes its localStorage copy and asks the command, the localStorage backend removes its item. forgetLocalE2EState() deletes the vault, then removes its key, and never rejects: what it cannot remove is logged and the account deletion still completes (its wait for the vault's delete request is bounded). Logout never calls it and keeps both. The Cookie Policy (English and French, dated November 18, 2026) and the protocol spec say the key is deleted with the vault.
  • The local cleanup of an account deletion completes before the app leaves the page. deleteAccount marks the deletion in flight (services/accountDeletion.ts) from before its request goes out until its local cleanup has finished after a successful answer (the vault, its key, the pins, the trusted-device token, that clear flushed to the token store), or until the request failed, which erases nothing: the account may still exist. The force:logout handler (after its own logout and token flush, as before) and the lost-session path (after its flush) wait for it before they navigate, for 90 seconds at most, then log one warning and navigate. Neither erases anything on the word of a force:logout: the first one comes before the server's transaction. With no deletion in flight both behave as before. Every action that starts a session (a sign-in, the two-factor step, both sign-up steps, a password change's renewed pair, a session restore) waits for a deletion in flight before it sends anything, so the cleanup never signs out or clears a session started from the login page meanwhile. The other ways a page could change during a deletion go through one of these two: a refused request or a refused socket handshake ends in the lost-session path, and another tab's sign-out only updates this tab's memory.
  • The native download contacts only an origin the build's policy allows (The desktop app's native avatar download fetches from whatever host the webview names #122). The shell reads the content security policy the app was built with from its compiled configuration (a policy string or a map of directives) and accepts the API base only when its origin (scheme, host and port; a default port written out or not) is an http(s) origin that connect-src names exactly. A wildcard source, a keyword, a scheme source, a ws(s) source, a source with a path and Tauri's own IPC host match nothing; a base with credentials, a query or a fragment is refused. A debug build also accepts http on localhost and 127.0.0.1, any port. A refused base fails the command before any request, and the notification falls back to the plugin. The apiBase argument stays (the webview passes its build-time constant) and is only compared. The request is built from the checked base, asks the server for the proxied image (?inline), follows no redirect, and treats any answer other than a success as a failure; the key, size, image-signature and symlink checks are unchanged.
  • Tauri code loads only in the Tauri app (notifications.ts statically imports Tauri modules, so every browser session loads desktop-only code #123). notifications.ts loads both modules with import() on the Tauri path, on first use, kept for later calls (a failed load is tried again). The three tiers behave as before; each catch now logs why a tier failed, once per distinct reason. A Vite plugin, scripts/browserEntryGuard.mjs, fails a production build when a chunk the browser loads at startup (an entry chunk or one it imports statically) holds a @tauri-apps module, and names the package.
  • External links open from one place in the app (External links depend on the deprecated shell plugin's injected click handler #126). tauri-plugin-shell is replaced by tauri-plugin-opener 2.7.3 (Rust crate and @tauri-apps/plugin-opener, both MIT OR Apache-2.0), registered with its own injected click script turned off; the single-instance plugin stays the first one registered. The capability grants opener:allow-open-url scoped to http://*, https://* and mailto:*, with the system's default application only, and no shell: permission. utils/externalLinks.ts installs, in the Tauri app only, one click handler on the document, in the capture phase (ahead of the app's own handlers, so a modal or a portal that stops a click's propagation cannot keep a link from it): a primary-button click on an anchor with target="_blank" whose href attribute, parsed without a base, is an http, https or mailto URL is opened through openUrl and its default prevented. A scheme-relative href (//host/path) is opened over https, as a browser on an https page opens it. A failure is logged as one fixed line that carries nothing of the error. A relative href, any other scheme (tel: included: the app has no such link) and any other target are left to the webview. The browser build installs nothing and opens links in a new tab as before.
  • No command blocks the window's thread. e2e_pickle_key_get, e2e_pickle_key_set, e2e_pickle_key_delete and notify_with_avatar are async, with their blocking work on the blocking pool like the session commands; a join failure is answered as an error string. Their names, arguments, results and error strings are unchanged. notify_with_avatar reads the build's configuration, then checks the base, downloads, caches and shows the toast on the blocking pool: the toast library makes plain WinRT calls with no apartment of its own, which run on any thread, and Tauri's notification plugin shows its toasts from a runtime task as well.

For people who build their own app

  • A notification avatar on Windows needs the API origin (scheme, host, port) to be an exact source of the built policy's connect-src. pnpm tauri:build writes it so; a policy written by hand must name it exactly, since a wildcard source matches nothing for the native download.

Key files

  • apps/desktop/src-tauri/src/lib.rs (e2e_pickle_key_delete, allowed_avatar_base, connect_src_of, avatar_url, download_avatar, show_avatar_toast, the plugin registration in run())
  • apps/desktop/src-tauri/Cargo.toml, Cargo.lock, capabilities/default.json, gen/schemas/*
  • apps/desktop/src/services/e2e/pickleKeyProvider.ts, apps/desktop/src/services/e2e/e2eService.ts (forgetLocalE2EState), apps/desktop/src/stores/authStore.ts (deleteAccount)
  • apps/desktop/src/services/accountDeletion.ts, apps/desktop/src/services/socket.ts (force:logout), apps/desktop/src/services/session.ts (handleSessionLost)
  • apps/desktop/src/services/notifications.ts, apps/desktop/scripts/browserEntryGuard.mjs, apps/desktop/vite.config.ts
  • apps/desktop/src/utils/externalLinks.ts, apps/desktop/src/main.tsx
  • apps/desktop/src/components/legal/CookiePolicyContent.en.tsx and .fr.tsx, docs/e2e-dm-spec.md (§7.3)
  • apps/desktop/package.json, pnpm-lock.yaml

Cargo.lock gains tauri-plugin-opener 2.7.3 and loses tauri-plugin-shell, os_pipe, shared_child, encoding_rs, core_detect and multiversion_no_op; no other package moves, and the tree still links one webview2-com (0.39.1). pnpm-lock.yaml gains @tauri-apps/plugin-opener 2.7.3 on the @tauri-apps/api 2.12.4 already locked.

Migrations

None.

Tests

  • Rust (apps/desktop/src-tauri, 43 unit tests):
    • The pickle-key delete refuses a malformed user id like the get and set commands, takes a missing entry as deleted, and reports a store that refuses. With the keyring mock store, which keeps one credential per entry, a removal clears the entry it is handed and leaves another account's entry alone; which entry a user id opens is pickle_key_entry, the call the read and the write make, which the mock cannot show.
    • The origin check over a policy string and a base: the matching origin with or without a path or trailing slash, another host, scheme or port, default ports written out, wildcard sources, 'self', ipc:, http://ipc.localhost and ws(s) sources, sources with a path, credentials, queries and fragments, the first connect-src only, the map form of the policy, the official policy, the debug-only loopback rule. The request URL on the checked base with ?inline.
    • Against a local server: the image is fetched from the path asked, a 301, 302 or 307 is a failure and is not followed, and an error answer, an empty body, a non-image and an oversized body are refused. The command checks the base before the cache and the download.
    • Every registered command is async, with its blocking work on the blocking pool and a join failure answered as an error.
    • cargo fmt --check, cargo check --locked, cargo check --locked --release, cargo clippy --locked --all-targets -- -D warnings and cargo test --locked pass; cargo audit reports the six allowed warnings develop already has and nothing else.
  • Desktop:
    • Both key providers' remove; forgetLocalE2EState (the vault goes before its key, a blocked or failing delete still removes the key, the bounded wait, never rejects); logout never calls it, also checked over the sources.
    • A force:logout while deleteAccount is pending: the page changes only once the vault and its key are gone, the pins removed and the trusted-device clear flushed, also when the answer arrives during the handler's token flush; a deletion that fails (409, 500, network error) erases nothing and the page still changes; the 90-second bound; the lost-session path waits the same way; a sign-in, the two-factor step, both sign-up steps, a password change and a session restore send nothing until the deletion has ended, and the cleanup clears nothing of the new session; with no deletion in flight both page changes happen right after their flush and a sign-in posts at once, as before.
    • Notifications in the Tauri app (the build's base handed to the shell, a refusal falling back to the plugin and logged once, the permission request, the Web fallback, a module loaded once and loaded again after a failed load) and in a browser (the Web Notification API, no Tauri module loaded); the build guard over output bundles and a scan that no source outside the tests imports @tauri-apps statically.
    • The link handler: http, https, mailto and scheme-relative links opened through the plugin; javascript:, file:, tel:, a relative href, ///x, // alone, another target, a click already taken and another button left alone; a link under an element, or inside a React portal, that stops the click's propagation still opened; a failure logged as a fixed line, with nothing of a rejection that carries the address; not installed in a browser.
    • The capability file pinned whole (no shell:, the opener scope exactly the three patterns), matching the compiled gen/schemas/capabilities.json; a self-hosted policy names the API origin exactly.
  • pnpm typecheck, pnpm lint and pnpm build:desktop pass (the build guard included). pnpm test: server 4779 passed (145 files), desktop 3362 passed and 1 skipped (197 files), admin 153 passed (15 files).

To check on an installed build

  1. Links. In a message, post https://example.org, [mail](mailto:someone@example.org) and [rel](//example.org/a), and click each: the first and the third open in the system browser (the third as https://example.org/a), the second in the mail client, and no window opens inside the app. Signed out, on the sign-up page, open the Privacy Policy from its consent box and click a contact address and a web link (the CNIL's, for one): same result, from inside the modal. Post [x](/settings) and click it: nothing happens. (A tel: link cannot be checked in a message: the message renderer drops that scheme and renders the link with an empty address. The handler leaves tel: to the webview, as its tests show.)
  2. Notification with an avatar (Windows). With the app in the tray, have a user who has an avatar send you a direct message: the toast shows their round avatar. Then delete %TEMP%\voxium_avatars and repeat: the avatar is downloaded again and shown. While a notification arrives, the window stays responsive.
  3. Account deletion. Sign in with a test account on the installed app, open an encrypted conversation so the vault and its key exist, and confirm the entry named after the account's user id under the service app.voxium.e2e-pickle-key in Windows Credential Manager (Generic Credentials). Sign out and back in: the entry and the encrypted history are still there. Delete the account from Settings: the app ends on the login page, and the credential-store entry is gone. In the browser build, do the same and check in the developer tools that the IndexedDB database voxium-e2e-v2-<userId> and the local-storage item voxium_e2e_pk_<userId> are gone and that the tab ends on the login page.
  4. A self-hosted build. Build with pnpm tauri:build for a test server and install it under its own product and binary names. A notification from a user with an avatar shows the avatar, and links open in the system browser as in step 1.

Issues: #121, #122, #123, #126

…deleted

Self-service account deletion dropped the local E2E vault but left the key
that opens it on the device: in the OS credential store in the desktop app,
and in localStorage in the browser build or wherever a keychain write had
fallen back to it.

The shell gains e2e_pickle_key_delete(user_id), beside the get and set
commands: the same user-id check, the service from keychain_services, and a
missing entry counts as deleted; the keychain call runs on the blocking pool,
off the window's thread. PickleKeyProvider gains remove(userId): the
keychain backend removes its localStorage copy and asks the command, the
localStorage backend removes its item. forgetLocalE2EState() deletes the
vault, then removes its key, and never rejects: a vault or a key it cannot
remove is logged and the account deletion still completes (the wait for the
vault's delete request is bounded). deleteAccount waits for it; logout never
calls it and keeps both.

The Cookie Policy (English and French, its "Last updated" date moved to
November 18, 2026) and the protocol spec now say the key is deleted with the
vault.

Closes #121
…app's policy allows

The native avatar download (Windows notifications) took the API base the
webview passed and checked only that it started with http:// or https://.
A native request is not bound by the webview's content security policy, and
it also followed redirects.

The shell now compares that base with the policy the app was built with,
read from its compiled configuration (a policy string or a map of
directives): it is accepted only when its origin (scheme, host, port, a
default port written out or not) is an http(s) origin that the policy's
connect-src names exactly. A wildcard source, a keyword, a scheme source, a
ws(s) source, a source with a path and Tauri's own IPC host match nothing; a
base with credentials, a query or a fragment is refused. A debug build also
accepts http on localhost and 127.0.0.1, on any port. A refused base fails
the command before any request (the notification falls back to the plugin
and the reason is logged once); the apiBase argument stays and is only ever
compared.

The request URL is built from the checked base and asks the server to proxy
the image (?inline); no redirect is followed, and any answer other than a
success is a failure. The key, size, image-signature and symlink checks are
unchanged. The webview logs each distinct reason a notification tier failed
once.

Closes #122
…Tauri app

services/notifications.ts imported @tauri-apps/plugin-notification and
@tauri-apps/api/core statically, the only file under apps/desktop/src that
did, so every browser session downloaded and ran desktop-only code.

Both modules are now loaded with import() on the Tauri path only, each on
first use and kept for later calls (a failed load is tried again next time).
The three tiers behave as before: the shell's command, then the
notification plugin, then the Web Notification API. Each catch now logs the
reason a tier failed, once per distinct reason.

A Vite plugin (scripts/browserEntryGuard.mjs, registered in vite.config.ts)
fails a production build when a chunk the browser loads at startup, an entry
chunk or one it imports statically, holds a @tauri-apps module, naming the
package. Tests cover the guard over output bundles, a scan that no file under
src outside the tests imports @tauri-apps statically, and notify() and
initNotifications() in both builds: a browser session loads no Tauri module.

Closes #123
… one app handler

External links (target="_blank": message links, the legal documents' web and
mail links) opened in the system browser only through the click script that
tauri-plugin-shell injects; nothing in the app's source showed it, and the
plugin's open API is deprecated in favour of tauri-plugin-opener.

tauri-plugin-shell is replaced by tauri-plugin-opener 2.7.3 (Rust crate and
@tauri-apps/plugin-opener, both MIT OR Apache-2.0). The plugin is registered
with its own injected click script turned off; the single-instance plugin
stays the first one registered. The capability grants
opener:allow-open-url scoped to http://*, https://* and mailto:* (the
system's default application only) and no shell permission.

utils/externalLinks.ts installs, in the Tauri app only, one click handler on
the document, in the capture phase, so a modal or a portal that stops a
click's propagation cannot keep a link from it: a primary-button click on an
anchor with target="_blank" whose href attribute, parsed without a base, is
an http, https or mailto URL is opened through openUrl (the plugin loaded
with import() on the first such click) and its default prevented. A
scheme-relative href (//host/path) is opened over https, as a browser on an
https page opens it. A failure is logged as one fixed line, nothing of the
error (which can carry the address, and a link can be an invite). Every
other link, a relative href and tel: included, is left to the webview. The browser build installs nothing.
main.tsx installs it before the first render.

Cargo.lock gains tauri-plugin-opener and loses tauri-plugin-shell, os_pipe,
shared_child, encoding_rs, core_detect and multiversion_no_op; pnpm-lock.yaml
gains @tauri-apps/plugin-opener (on the @tauri-apps/api already locked). The
generated permission schemas under gen/schemas follow.

Closes #126
…he app leaves the page

While the server deletes an account it ends the account's sessions: it sends
force:logout to every socket of the account, the deleting client's
included, before its transaction and again after the commit, and refuses
the account's other requests. The force:logout handler and the lost-session
path both change the page to the login page, with no link to the deletion
in flight: a page change before the answer skipped the whole local cleanup
(the vault, its key, the secure-channel pins, the trusted-device token), and
one during the cleanup could cut the key removal short.

deleteAccount now marks the deletion in flight from before its request goes
out (services/accountDeletion.ts, a module without imports) until its local
cleanup has finished after a successful answer, the trusted-device clear
flushed to the token store included, or until the request failed, which
erases nothing. The force:logout handler (after its own logout and token
flush, as before) and handleSessionLost (after its flush) wait for it before
they navigate, for 90 seconds at most, then log one warning and navigate.
Neither erases anything on the word of a force:logout. With no deletion in
flight both behave as before.

The login page is on screen during that wait. Every action that starts a
session (login, the two-factor step, both sign-up steps, a password
change's renewed pair, the session restore) waits for a deletion in flight
before it sends anything, so the cleanup's logout and trusted-device clear
never land on a session started meanwhile. With none in flight they await
nothing and keep today's order.

Refs #121
…'s thread

e2e_pickle_key_get, e2e_pickle_key_set and notify_with_avatar were
synchronous commands, which Tauri runs on the main thread: a keychain call
(Credential Manager, the Keychain, a D-Bus round trip to the Secret Service)
or the avatar download (up to 10 s), its file work and the toast held the
thread that paints the window. They are now async, with that work on the
blocking pool, as the session commands and e2e_pickle_key_delete already do;
a join failure is answered as an error string. Names, arguments, results and
error strings are unchanged.

notify_with_avatar reads the build's configuration on the calling side and
does the base check, the download, the cache and the toast on the blocking
pool. The toast keeps no thread of its own: tauri-winrt-notification makes
plain WinRT calls with no apartment set up, which windows-core runs in the
process's multithreaded apartment on any thread, and Tauri's notification
plugin shows its toasts from a runtime task as well.

A source test pins every registered command as async, with its blocking work
on the blocking pool.
@Aizen93
Aizen93 merged commit 8db52e8 into develop Nov 19, 2026
8 checks passed
@Aizen93
Aizen93 deleted the fix/desktop-shell-hygiene branch November 20, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant